﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:sw="clr-namespace:System.Windows;assembly=PresentationFramework"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="OdigoMisc2.xaml"/>
        <ResourceDictionary Source="OdigoUserProfile.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/ShredTheLog.Themes;component/AppIcon.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <GridLength x:Key="WindowCornerLength">20</GridLength>

    <Style x:Key="WindowTitleBarButton" TargetType="{x:Type Button}">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Foreground" Value="#BEC5CE"/>
        <Setter Property="Width" Value="12"/>
        <Setter Property="Height" Value="12"/>
        <Setter Property="Margin" Value="2, 0, 2, 0"/>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="White"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Foreground" Value="#3E65F6"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TranslateTransform X="1" Y="1"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type c:WindowMinimizeButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>
    <Style TargetType="{x:Type c:WindowMaximizeButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>
    <Style TargetType="{x:Type c:WindowCloseButton}" BasedOn="{StaticResource WindowTitleBarButton}"/>

    <Style x:Key="RoundedWindow" TargetType="{x:Type Window}">
        <Style.Resources>
            <CornerRadius x:Key="WindowCornerRadius">20</CornerRadius>

            <Style TargetType="{x:Type c:WindowTitleBar}">
                <Setter Property="Foreground" Value="#D4DEE9"/>
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="Padding" Value="8, 2, 8, 2"/>
                <Setter Property="Margin" Value="0, 0, 0, 0"/>
            </Style>

        </Style.Resources>

        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="AllowsTransparency" Value="True"/>

        <Setter Property="Icon" Value="{StaticResource AppIcon}"/>
        <Setter Property="c:WindowIcon.Icon" Value="OdigoImages\OdigoMainWindow.ico"/>

        <Setter Property="Background" Value="{StaticResource BlueWindowBackgroundBrush}"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <AdornerDecorator>
                        <!--Фон окна-->
                        <Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="{StaticResource WindowCornerRadius}" BorderBrush="{TemplateBinding BorderBrush}">

                            <Grid>
                                <Grid.Clip>
                                    <MultiBinding Converter="{x:Static cnv:RectangleGeometryConverter.Default}">
                                        <Binding ElementName="border" Path="ActualWidth"/>
                                        <Binding ElementName="border" Path="ActualHeight"/>
                                        <Binding ElementName="border" Path="CornerRadius.BottomLeft"/>
                                        <Binding ElementName="border" Path="BorderThickness.Left"/>
                                    </MultiBinding>
                                </Grid.Clip>

                                <!--Объемная рамка окна-->
                                <Grid>
                                    <Panel.Effect>
                                        <BlurEffect KernelType="Gaussian" RenderingBias="Performance" Radius="5"/>
                                    </Panel.Effect>
                                    <Border BorderThickness="2, 2, 0, 0" BorderBrush="#FFFFFF" CornerRadius="{StaticResource WindowCornerRadius}"/>
                                    <Border BorderThickness="0, 0, 2, 2" BorderBrush="#000000" CornerRadius="{StaticResource WindowCornerRadius}"/>
                                </Grid>

                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="{StaticResource WindowCornerLength}"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="{StaticResource WindowCornerLength}"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="{StaticResource WindowCornerLength}"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="{StaticResource WindowCornerLength}"/>
                                    </Grid.RowDefinitions>

                                    <c:WindowTopBorder Grid.Column="1" Grid.Row="0"/>
                                    <c:WindowBottomBorder Grid.Column="1" Grid.Row="2"/>
                                    <c:WindowLeftBorder Grid.Column="0" Grid.Row="1"/>
                                    <c:WindowRightBorder Grid.Column="2" Grid.Row="1"/>
                                    <c:WindowTopLeftCorner Grid.Column="0" Grid.Row="0"/>
                                    <c:WindowTopRightCorner Grid.Column="2" Grid.Row="0"/>
                                    <c:WindowBottomLeftCorner Grid.Column="0" Grid.Row="2"/>
                                    <c:WindowBottomRightCorner Grid.Column="2" Grid.Row="2"/>

                                    <DockPanel Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="{TemplateBinding Padding}">
                                        <c:WindowTitleBar DockPanel.Dock="Top">
                                            <c:WindowTitleBar.Title>
                                                <TextBlock Text="{TemplateBinding Title}" TextTrimming="CharacterEllipsis"/>
                                            </c:WindowTitleBar.Title>
                                        </c:WindowTitleBar>
                                        <ContentPresenter Content="{TemplateBinding Content}"/>
                                    </DockPanel>

                                    <ResizeGrip x:Name="WindowResizeGrip" Grid.ColumnSpan="3" Grid.RowSpan="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" IsTabStop="false"/>
                                </Grid>

                            </Grid>
                        </Border>
                    </AdornerDecorator>
                    
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Window.ResizeMode" Value="CanResizeWithGrip"/>
                                <Condition Property="Window.WindowState" Value="Normal"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="AngularWindow" TargetType="{x:Type Window}">
        <Style.Resources>
            <Style TargetType="{x:Type c:WindowTitleBar}">
                <Setter Property="Foreground" Value="#D4DEE9"/>
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="Padding" Value="1"/>
                <Setter Property="Margin" Value="0"/>
            </Style>
        </Style.Resources>

        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="AllowsTransparency" Value="True"/>

        <Setter Property="Icon" Value="{StaticResource AppIcon}"/>
        <Setter Property="c:WindowIcon.Icon" Value="OdigoImages\OdigoMainWindow.ico"/>

        <Setter Property="Background" Value="#475673"/>
        <Setter Property="Padding" Value="2, 3, 2, 2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <AdornerDecorator>
                        <!--Фон окна-->
                        <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="#030304" BorderThickness="1">

                            <Grid>
                                <Grid.Clip>
                                    <MultiBinding Converter="{x:Static cnv:RectangleGeometryConverter.Default}">
                                        <Binding ElementName="border" Path="ActualWidth"/>
                                        <Binding ElementName="border" Path="ActualHeight"/>
                                        <Binding ElementName="border" Path="CornerRadius.BottomLeft"/>
                                        <Binding ElementName="border" Path="BorderThickness.Left"/>
                                    </MultiBinding>
                                </Grid.Clip>

                                <!--Объемная рамка окна-->
                                <Grid>
                                    <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="#39475B"/>
                                    <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="#475673" Margin="1"/>
                                    <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="1" Fill="#475673"/>
                                    <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="1" Fill="#728BA0" Margin="1"/>
                                    <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="1" Fill="#728BA0" Margin="2"/>
                                </Grid>

                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="{StaticResource WindowCornerLength}"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="{StaticResource WindowCornerLength}"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="{StaticResource WindowCornerLength}"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="{StaticResource WindowCornerLength}"/>
                                    </Grid.RowDefinitions>

                                    <c:WindowTopBorder Grid.Column="1" Grid.Row="0"/>
                                    <c:WindowBottomBorder Grid.Column="1" Grid.Row="2"/>
                                    <c:WindowLeftBorder Grid.Column="0" Grid.Row="1"/>
                                    <c:WindowRightBorder Grid.Column="2" Grid.Row="1"/>
                                    <c:WindowTopLeftCorner Grid.Column="0" Grid.Row="0"/>
                                    <c:WindowTopRightCorner Grid.Column="2" Grid.Row="0"/>
                                    <c:WindowBottomLeftCorner Grid.Column="0" Grid.Row="2"/>
                                    <c:WindowBottomRightCorner Grid.Column="2" Grid.Row="2"/>

                                    <Border Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="{TemplateBinding Padding}" BorderBrush="#4D6585" BorderThickness="1">
                                        <DockPanel>
                                            <c:WindowTitleBar DockPanel.Dock="Top">
                                                <c:WindowTitleBar.Title>
                                                    <TextBlock Text="{TemplateBinding Title}" TextTrimming="CharacterEllipsis"/>
                                                </c:WindowTitleBar.Title>
                                            </c:WindowTitleBar>
                                            <Rectangle DockPanel.Dock="Top" Height="1" Stroke="{x:Null}" Fill="#4D6585" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
                                            <Border BorderBrush="#030304" BorderThickness="1" Background="#BAD0E4">
                                                <ContentPresenter Content="{TemplateBinding Content}"/>
                                            </Border>
                                        </DockPanel>
                                    </Border>

                                    <ResizeGrip x:Name="WindowResizeGrip" Grid.ColumnSpan="3" Grid.RowSpan="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" IsTabStop="false"/>
                                </Grid>
                            </Grid>
                        </Border>
                    </AdornerDecorator>

                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Window.ResizeMode" Value="CanResizeWithGrip"/>
                                <Condition Property="Window.WindowState" Value="Normal"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type v:MainView}" BasedOn="{StaticResource RoundedWindow}">
        <Setter Property="Width" Value="188"/>
        <Setter Property="Height" Value="382"/>
        <Setter Property="MinWidth" Value="188"/>
        <Setter Property="MinHeight" Value="382"/>
        <Setter Property="ResizeMode" Value="CanMinimize"/>
        <Setter Property="Title" Value="{c:LocalizedString s_AppTitle}"/>
    </Style>

    <Style TargetType="{x:Type v:UserProfileView}" BasedOn="{StaticResource RoundedWindow}">
        <Style.Resources>
            <DataTemplate DataType="{x:Type vm:UserProfileViewModel}">
                <Grid Margin="3, 2, 3, 3">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource UserProfileContentTemplate}"/>

                    <!--Нижняя синяя панель с кнопками-->
                    <Grid Grid.Row="1" Margin="3, 0, 3, 0">
                        <Panel.Resources>
                            <Style x:Key="CommandButton" TargetType="{x:Type Button}" BasedOn="{StaticResource WizButtonStyle}">
                                <Setter Property="MinWidth" Value="57"/>
                                <Setter Property="Margin" Value="8, 5, 0, 0"/>
                            </Style>
                        </Panel.Resources>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="1" Content="{c:LocalizedString s_Cancel}" Style="{StaticResource CommandButton}" Command="{Binding CloseCommand}"/>
                        <Button Grid.Column="2" Content="{c:LocalizedString s_Talk}" Style="{StaticResource CommandButton}" Command="{Binding RequestPrivateChatCommand}" CommandParameter="{Binding}"/>
                    </Grid>
                </Grid>
            </DataTemplate>
        </Style.Resources>

        <Setter Property="Width" Value="270"/>
        <Setter Property="Height" Value="355"/>
        <Setter Property="MinWidth" Value="270"/>
        <Setter Property="MinHeight" Value="355"/>
        <Setter Property="Title" Value="{c:LocalizedString s_DetailsCard}"/>
    </Style>

    <Style TargetType="{x:Type v:TextChatRoomView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Title" Value="{Binding Path=RoomName, Converter={x:Static cnv:RoomConverter.Default}}"/>
        <Setter Property="Width" Value="600"/>
        <Setter Property="Height" Value="400"/>
        <Setter Property="MinWidth" Value="600"/>
        <Setter Property="MinHeight" Value="400"/>
    </Style>

    <Style TargetType="{x:Type v:AboutView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="ResizeMode" Value="CanMinimize"/>
        <Setter Property="SizeToContent" Value="WidthAndHeight"/>
        <Setter Property="Title" Value="{Binding Path=Product, StringFormat={c:LocalizedString s_AboutDialogTitle}}"/>
    </Style>

    <Style TargetType="{x:Type v:LogInView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="Height" Value="150"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="MinHeight" Value="150"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="Title" Value="{c:LocalizedString s_LogIn}"/>
    </Style>

    <Style TargetType="{x:Type v:SettingsView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Width" Value="550"/>
        <Setter Property="Height" Value="400"/>
        <Setter Property="MinWidth" Value="550"/>
        <Setter Property="MinHeight" Value="400"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{c:LocalizedString s_Settings}"/>
    </Style>

    <Style TargetType="{x:Type v:ErrorView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Width" Value="400"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{c:LocalizedString s_ShredTheLogError}"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
    </Style>

    <Style TargetType="{x:Type v:InputView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{Binding WindowTitle}"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
    </Style>

    <Style TargetType="{x:Type v:MessageDialogView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="Height" Value="150"/>
        <Setter Property="MinHeight" Value="150"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{Binding WindowTitle}"/>
    </Style>

    <Style TargetType="{x:Type v:PrivateChatRequestView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Width" Value="300"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="Height" Value="400"/>
        <Setter Property="MinHeight" Value="400"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{Binding Path=Caller.Name, StringFormat={c:LocalizedString s_PrivateChatRequestFrom}}"/>
    </Style>

    <Style TargetType="{x:Type v:UserSearchConditionsView}" BasedOn="{StaticResource AngularWindow}">
        <Setter Property="Width" Value="400"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="SizeToContent" Value="Height"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="ShowInTaskbar" Value="True"/>
        <Setter Property="Title" Value="{c:LocalizedString s_Conditions_UserSearch}"/>
    </Style>

</ResourceDictionary>